<?php
/**
 * Created by PhpStorm.
 * User: lyon
 * Date: 16-12-5
 * Time: 下午10:27
 */
namespace app\admin\model;

use think\Model;

class Zombie extends Model
{
    public static function insert($data = array())
    {
        if (!empty($data))
        {
            $user = new Zombie;
            foreach ($data as $key => $value) {
                $user->$key = $value;
            }
            if ($user->save())
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            return false;
        }
    }
    public static function getUserName()
    {
        $user = new Zombie;
        $listName = $user->where('issearch = 0')->field(array('u_name','id'))->limit(1)->order('id desc')->select();
        foreach ($listName as $key => $value) {
            $id = $listName[$key]['id'];
            $user->save([
                'issearch' => 1
            ], ['id' => $id]
            );
        }
        if ($listName)
        {
            return $listName;
        }
        else
        {
            return false;
        }
    }
    public static function backError($id)
    {
        $user = new Zombie;

        if ($user->where('id', $id)->update(['issearch' => 2]))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    public static function updateUser($id, $data)
    {
        $user = new Zombie;

        if ($user->where('id', $id)->update($data))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}